﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace CommonLibrary
{
    public class CompressExt
    {
        public static string Zip(string strInput)
        {
            return Regex.Replace(strInput, @"(.)\1*", m => m.Groups[1].Value + "*" + m.Value.Length);
        }

        public static string UnZip(string strInput)
        {
            //strInput.Split('',2);
            return Regex.Replace(strInput, @"(.)\1*", m => m.Groups[1].Value + m.Value.Length);
        }
    }
}
